package com.hxzy.projectssmplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxzy.projectssmplus.dto.SysDicDataDTO;
import com.hxzy.projectssmplus.entity.SysDictData;
import com.hxzy.projectssmplus.mapper.SysDictDataMapper;
import com.hxzy.projectssmplus.mapper.SysDictTypeMapper;
import com.hxzy.projectssmplus.service.SysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper,SysDictData> implements SysDictDataService{

    @Autowired
    private SysDictDataMapper sysDictDataMapper;

    @Override
    public List<SysDictData> searchByXML(SysDicDataDTO sysDicDataDTO) {

        List<SysDictData> sysDictData = this.sysDictDataMapper.searchByXML(sysDicDataDTO);
        return sysDictData;
    }

    @Override
    public Integer addData(SysDictData sysDictData) {

        int insert = this.sysDictDataMapper.insert(sysDictData);
        return insert;
    }

    @Override
    public Integer delData(Long dictCode) {

        int i = this.sysDictDataMapper.deleteById(dictCode);
        return i;
    }

    @Override
    public Integer upDataData(SysDictData sysDictData) {
        int i = this.sysDictDataMapper.updateById(sysDictData);

        return i;
    }

    @Override
    public Integer updateDictData(SysDictData sysDictData) {
        Integer integer = this.sysDictDataMapper.updateDictData(sysDictData);
        return integer;
    }

    @Override
    public List<SysDictData> searchByType(String type) {
        QueryWrapper<SysDictData> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("dict_type",type).eq("status",0);
        List<SysDictData> sysDictData = this.sysDictDataMapper.selectList(queryWrapper);
        return sysDictData;
    }


}
